package com.tourism.user.cn.controller;
/*********************************************************************
 Copyright(c) 2024 All Rights Reserved .
 Author : liliang
 CreatedOn : 2024/12/27 21:29
 Email : 2061996582@qq.com
 Describe : 短信发送控制器
 UseCase :
 Version : 2024|V1.0.0.0
 **********************************************************************/

import com.tourism.core.cn.dto.SendSmsDto;
import com.tourism.core.cn.enums.ResultCodeEnum;
import com.tourism.core.cn.result.Result;
import com.tourism.user.cn.service.SmsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author new
 * @date 2024/12/27 21:29
 */
@Slf4j
@RestController
@RequestMapping("/sms")
public class SmsController {
    @Autowired
    private SmsService smsService;


    @PostMapping("/sendSms")
    public Result<Boolean> sendSms(@RequestBody SendSmsDto smsDto){
        // TODO 调用短信服务发送短信
        boolean isSuccess = smsService.sendSms(smsDto.getMobile());

        if (!isSuccess) {
            return Result.error(ResultCodeEnum.SMS_SEND_ERROR);
        }
        return Result.success(true);
    }

}
